package com.ejd.web.vo.genl;

import java.util.List;




import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.model.SelectItem;


import com.ejd.service.IShoesStyleService;
import com.ejd.utils.MessageFactory;
import com.ejd.utils.SpringFacesUtil;
import com.ejd.web.bo.impl.ShoesStyle;
import com.ejd.web.constant.EjdConstants;
import com.ejd.web.constant.SpringBeanConstants;

@ManagedBean(name="existShoesStyle")
@SessionScoped
public class ExistShoesStyleBean implements java.io.Serializable {

	private SelectItem[] shoesStyleItems;

	public SelectItem[] getShoesStyleItems() {
		return shoesStyleItems;
	}

	public void setShoesStyleItems(SelectItem[] shoesStyleItems) {
		this.shoesStyleItems = shoesStyleItems;
	}
	public ExistShoesStyleBean() {
		
		IShoesStyleService<ShoesStyle,Long> shoesStyleService = (IShoesStyleService<ShoesStyle,Long>)SpringFacesUtil.getSpringBean(SpringBeanConstants.SHOES_STYLE_SERVICE_BEAN_NAME);
		shoesStyleService.setEntityClass(ShoesStyle.class);
		shoesStyleService.setPKClass(Long.class);
		List<ShoesStyle> shoesStyles = shoesStyleService.getAll();
		SelectItem[] tempShoesStyleItems = new SelectItem[shoesStyles.size()];
		if (null != shoesStyles && !(shoesStyles.isEmpty())) {
			for (int i=0; i< tempShoesStyleItems.length; i++) {
				ShoesStyle shoesStyle = (ShoesStyle) shoesStyles.get(i);
				String shoesStyleNameN18 = MessageFactory.getMessage(EjdConstants.USER_BUNDLE_NAME,shoesStyle.getStyleName(), FacesMessage.SEVERITY_ERROR).getDetail();
				tempShoesStyleItems[i] = new SelectItem(shoesStyle.getStyleCode(),shoesStyleNameN18);
			}
		}
		this.setShoesStyleItems(tempShoesStyleItems);
	}
}
